﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace SevenInvaders.LEVEL_GABE
{


    class GabePlayer : Player
    {
        animation giro;
        
        public GabePlayer(Texture2D texture, Vector2 position, int player, GameWindow qg,
            ContentManager Content) :
            base(texture, position, player, qg, Content)
        {
            this.Position = new Vector2(Window.ClientBounds.Width/2, Window.ClientBounds.Height/2);

            this.Velocity = new Vector2(10, 0);

            this.Window = qg;

            giro = new animation();
            giro.frame.X = 0;
            giro.frame.Y = 0;
            giro.frame.Width = 56;
            giro.frame.Height = 40;

            giro.frames = 12;
            giro.fps = 24;

            current_animation = giro;
        }

        public void Update(GameTime gameTime, KeyboardState ks)
        {
            if (this.PositionX - 23 <= 0)
            {
                this.PositionX = 23;
            }

            if (this.PositionX + 23 >= Window.ClientBounds.Width)
            {
                this.PositionX = Window.ClientBounds.Width - 23;
            }

            if (this.PositionY - 20 <= 0)
            {
                this.PositionY = 20;
            }

            if (this.PositionY + 20 >= Window.ClientBounds.Height)
            {
                this.PositionY = Window.ClientBounds.Height - 20;
            }
            if (ks.IsKeyDown(Keys.Right))
            {
                this.Right = true;
                this.PositionX += 3;// this.Velocity.X;
                this.Pivot = new Vector2(23, 20);
                this.Rotation = 15;
               
            }
            else if (ks.IsKeyDown(Keys.Left))
            {
                this.Right = false;
                this.PositionX -= 3;// this.Velocity.X;
                this.Pivot = new Vector2(23, 20);
                this.Rotation = -15;
            }
            else if (ks.IsKeyDown(Keys.Up))
            {
                this.Right = false;
                this.PositionY -= 3;
                this.Pivot = new Vector2(23, 20);
                this.Rotation = 0;
            }
            else if (ks.IsKeyDown(Keys.Down))
            {
                this.Right = false;
                this.PositionY += 3;
                this.Pivot = new Vector2(23, 20);
                this.Rotation = 0;
            }
            else
            {
                this.Pivot = new Vector2(23, 20);
                //zerando o pivot por duvida se ira alterar a colisao
                this.Rotation = 0;
            }

        }
    }
}
